package com.liuwei.learning.restful;

import com.liuwei.learning.jpa.testdb1.Article;
import com.liuwei.learning.jpa.testdb1.ArticleRepository;
import com.liuwei.learning.model.ArticleVO;
import com.liuwei.learning.utils.DozerUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RunWith(SpringRunner.class)
@AutoConfigureWebMvc
@SpringBootTest
public class ArticleRestControllerTest6 {

    @Resource
    private ArticleRepository articleRepository;


    @Test
    public void findAll(){
        PageRequest pageable = PageRequest.of(0,2);
        Page<Article> articlePage = articleRepository.findAll(pageable);
        List<Article> articleList = articlePage.getContent();
        List<ArticleVO> articleVOS = DozerUtils.mapList(articleList,ArticleVO.class);
        log.info(articleVOS.toString());
    }




}
